﻿<%@ Page Title="-" Language="C#" MasterPageFile="~/Administration/MasterPage.master" AutoEventWireup="true" CodeFile="Detail.aspx.cs" Inherits="Administration_Detail" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CPHMain" runat="Server">
    <altairis:AutoModeFormView ID="AutoModeFormView1" runat="server" DataKeyNames="EntryId" DataSourceID="LinqDataSource1" DefaultRedirectUrl="Default.aspx" DefaultMode="Edit" InsertPageTitle="New redirect entry" EditPageTitle="Edit redirect entry">
        <InsertItemTemplate>
            <table class="form">
                <tbody>
                    <tr>
                        <th>
                            <asp:Label ID="Label1" runat="server" Text="Host name:" AssociatedControlID="HostNameDropDownList" />
                        </th>
                        <td>
                            <asp:DropDownList ID="HostNameDropDownList" runat="server" SelectedValue='<%# Bind("HostId") %>' DataSourceID="LinqDataSourceHostName" DataTextField="HostName" DataValueField="HostId" Width="500px" />
                            <asp:LinqDataSource ID="LinqDataSourceHostName" runat="server" ContextTypeName="SwitchboardDataContext" OrderBy="HostName" Select="new (HostId, HostName)" TableName="Hosts" Where="UserName == @UserName">
                                <WhereParameters>
                                    <altairis:UserNameParameter Name="UserName" Type="String" />
                                </WhereParameters>
                            </asp:LinqDataSource>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <asp:Label ID="Label2" runat="server" Text="Local path (key):" AssociatedControlID="LocalPathTextBox" />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="LocalPathTextBox" Display="Dynamic" ErrorMessage="Local path is missing">*</asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="LocalPathTextBox" Display="Dynamic" ErrorMessage="Local path syntax invalid" ValidationExpression="[a-z0-9-_/]{1,}">*</asp:RegularExpressionValidator>
                            <asp:CustomValidator ID="CustomValidator1" runat="server" Display="Dynamic" ErrorMessage="This key is already taken" OnServerValidate="CustomValidator1_ServerValidate">*</asp:CustomValidator>
                        </th>
                        <td>
                            <asp:TextBox ID="LocalPathTextBox" runat="server" Text='<%# Bind("LocalPath") %>' Width="500px" />
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <asp:Label ID="Label3" runat="server" Text="Redirect type and location:" AssociatedControlID="RedirectTypeDropDownList" />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="RedirectLocationTextBox" Display="Dynamic" ErrorMessage="Redirect location is missing">*</asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="RedirectLocationTextBox" Display="Dynamic" ErrorMessage="Redirect location syntax invalid" ValidationExpression="http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&amp;=]*)?">*</asp:RegularExpressionValidator>
                        </th>
                        <td>
                            <asp:DropDownList ID="RedirectTypeDropDownList" runat="server" SelectedValue='<%# Bind("RedirectTypeId") %>' DataSourceID="LinqDataSourceRedirectType" DataTextField="Title" DataValueField="RedirectTypeId" Width="200px" AutoPostBack="true" OnSelectedIndexChanged="RedirectTypeDropDownList_SelectedIndexChanged" />
                            <asp:TextBox ID="RedirectLocationTextBox" runat="server" Text='<%# Bind("RedirectLocation") %>' Width="295px" />
                            <asp:LinqDataSource ID="LinqDataSourceRedirectType" runat="server" ContextTypeName="SwitchboardDataContext" OrderBy="Title" Select="new (RedirectTypeId, Title)" TableName="RedirectTypes" />
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <asp:Label ID="Label5" runat="server" Text="Notes:" AssociatedControlID="NotesTextBox" />
                        </th>
                        <td>
                            <asp:TextBox ID="NotesTextBox" runat="server" Text='<%# Bind("Notes") %>' Width="500px" Height="70px" TextMode="MultiLine" />
                        </td>
                    </tr>
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="2">
                            <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
                            <asp:Button ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Submit" />
                            <asp:Button ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                        </td>
                    </tr>
                </tfoot>
            </table>
        </InsertItemTemplate>
        <EditItemTemplate>
            <table class="form">
                <tbody>
                    <tr>
                        <th>Date created:</th>
                        <td>
                            <span class="strong" style="float: right">
                                <altairis:IconLinkButton runat="server" Icon="LinkDelete" CommandName="Delete" CausesValidation="false" AlternateText="Delete this redirect" ID="IconLinkButton1" />
                                <ajax:ConfirmButtonExtender ID="IconLinkButton1_ConfirmButtonExtender" runat="server" ConfirmText="Are you sure you want to delete this redirect?" Enabled="True" TargetControlID="IconLinkButton1" />
                                <asp:LinkButton runat="server" CommandName="Delete" CausesValidation="false" Text="Delete this redirect" ID="LinkButton1" />
                                <ajax:ConfirmButtonExtender ID="LinkButton1_ConfirmButtonExtender" runat="server" ConfirmText="Are you sure you want to delete this redirect?" Enabled="True" TargetControlID="LinkButton1" />
                            </span>
                            <altairis:DateLabel ID="DateLabel1" runat="server" DateValue='<%# Eval("DateCreated") %>' />
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <asp:Label ID="Label1" runat="server" Text="Location:" />
                        </th>
                        <td>
                            <asp:Label ID="Label4" runat="server" Text='<%# Eval("Location") %>' CssClass="code" />
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <asp:Label ID="Label3" runat="server" Text="Redirect type and location:" AssociatedControlID="RedirectTypeDropDownList" />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="RedirectLocationTextBox" Display="Dynamic" ErrorMessage="Redirect location is missing">*</asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="RedirectLocationTextBox" Display="Dynamic" ErrorMessage="Redirect location syntax invalid" ValidationExpression="http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&amp;=]*)?">*</asp:RegularExpressionValidator>
                        </th>
                        <td>
                            <asp:DropDownList ID="RedirectTypeDropDownList" runat="server" SelectedValue='<%# Bind("RedirectTypeId") %>' DataSourceID="LinqDataSourceRedirectType" DataTextField="Title" DataValueField="RedirectTypeId" Width="200px" AutoPostBack="true" OnSelectedIndexChanged="RedirectTypeDropDownList_SelectedIndexChanged" />
                            <asp:TextBox ID="RedirectLocationTextBox" runat="server" Text='<%# Bind("RedirectLocation") %>' Width="295px" />
                            <asp:LinqDataSource ID="LinqDataSourceRedirectType" runat="server" ContextTypeName="SwitchboardDataContext" OrderBy="Title" Select="new (RedirectTypeId, Title)" TableName="RedirectTypes" />
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <asp:Label ID="Label5" runat="server" Text="Notes:" AssociatedControlID="NotesTextBox" />
                        </th>
                        <td>
                            <asp:TextBox ID="NotesTextBox" runat="server" Text='<%# Bind("Notes") %>' Width="500px" Height="70px" TextMode="MultiLine" />
                        </td>
                    </tr>
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="2">
                            <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
                            <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Submit" />
                            <asp:Button ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                        </td>
                    </tr>
                </tfoot>
            </table>
        </EditItemTemplate>
    </altairis:AutoModeFormView>
    <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="SwitchboardDataContext" EnableDelete="True" EnableInsert="True" EnableUpdate="True" TableName="Entries" Where="EntryId == @EntryId && Host.UserName == @UserName">
        <WhereParameters>
            <asp:QueryStringParameter Name="EntryId" QueryStringField="EntryId" Type="Int32" />
            <altairis:UserNameParameter Name="UserName" Type="String" />
        </WhereParameters>
    </asp:LinqDataSource>
    <asp:Literal ID="LiteralNoHosts" runat="server" Text="You have assigned no hosts to manage. Contact system administrator." Visible="false" />
</asp:Content>
